package ch05.demo.dao.impl;

import ch05.demo.dao.UserDao;
import ch05.demo.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;

/**
 *  上机三
 */
@Component("userDao")
public class UserDaoImpl implements UserDao {
    @Autowired
    private UserDao dao;

    @Override
    public void save(User user) {
        System.out.println("保存用户信息到数据库");
    }

    public UserDao getDao() {
        return dao;
    }

    public void setDao(UserDao dao) {
        this.dao = dao;
    }

    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserDaoImpl bean = context.getBean(UserDaoImpl.class);
        User user = context.getBean(User.class);
        bean.save(user);

    }
}
